package com.quanyan.pay.service.impl;

import com.quanyan.pay.entity.TSNRecord;
import com.quanyan.pay.mapper.TSNRecordMapper;
import com.quanyan.pay.service.TsnService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author songzj
 * @date 16/6/1-16:51
 */
@Service("tsnService")
public class TsnServiceImpl implements TsnService {

    @Autowired
    private TSNRecordMapper tsnRecordMapper;

    @Override
    public TSNRecord insertTsnRecord(Integer payId, String dataType, String respData, String tsn, String orderNo, String tsnType) {
        TSNRecord tsnRecord = new TSNRecord();
        tsnRecord.setPayId(payId);
        tsnRecord.setDataType(dataType);
        tsnRecord.setRespDate(respData);
        tsnRecord.setTsn(tsn);
        tsnRecord.setOrderNo(orderNo);
        tsnRecord.setStatus(STATUS_INIT);
        tsnRecord.setTsnType(tsnType);
        this.tsnRecordMapper.insertSelective(tsnRecord);
        return tsnRecord;
    }

    public void updateTsnRecordStatus(Integer id, Byte status){
        TSNRecord tsnRecord = new TSNRecord();
        tsnRecord.setId(id);
        tsnRecord.setStatus(status);
        this.tsnRecordMapper.updateByPrimaryKeySelective(tsnRecord);
    }

}
